package cn.slipi.admin.service.impl;

import cn.slipi.admin.common.exception.base.BizException;
import cn.slipi.admin.dao.TSysRoleMapper;
import cn.slipi.admin.entity.TSysRole;
import cn.slipi.admin.service.TSysRoleService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 系统角色表 服务实现类
 * </p>
 *
 * @author lee
 * @since 2020-10-09
 */
@Service
public class TSysRoleServiceImpl extends ServiceImpl<TSysRoleMapper, TSysRole> implements TSysRoleService {

    @Override
    @Transactional(rollbackFor = BizException.class)
    public List<TSysRole> getRoleByRoleIds(List<Integer> roleIds) {
        /**
         *  select r from Role r where r.id in(:roleIds) and r.status = 1"
         */
        QueryWrapper<TSysRole> queryWrapper = new QueryWrapper<>();
        queryWrapper.in("ID", roleIds);
        queryWrapper.eq("STATUS", 1);
        return this.baseMapper.selectList(queryWrapper);
    }
}
